package com.reny.szkj.ft_login.ui.login

import com.alibaba.android.arouter.facade.annotation.Route
import com.reny.ll.git.base_logic.MActivity
import com.reny.ll.git.base_logic.config.RConfig
import com.reny.ll.git.base_logic.ext.onClick
import com.reny.ll.git.base_logic.ext.postEvent
import com.reny.ll.git.base_logic.ext.toast
import com.reny.ll.git.mvvm.extras.observe
import com.reny.szkj.ft_login.R
import com.reny.szkj.ft_login.databinding.ActivityLoginBinding
import org.kodein.di.android.closestDI
import org.kodein.di.android.subDI
import org.kodein.di.instance

@Route(path = RConfig.FtLogin.login)
class LoginActivity : MActivity<ActivityLoginBinding>() {

    override val di by subDI(closestDI()) {
        import(loginDIModule)
    }

    override val layoutId: Int = R.layout.activity_login

    override val viewModel: LoginViewModel by instance()

    override fun initView() {

        observe(viewModel.result){
            toast("Login success")
            it.postEvent()
            finish()
        }

        //delegateImp.getStateView()
        binding.btnLogin.onClick {
            viewModel.login(binding.etPhone.text.toString(), binding.etPwd.text.toString())
        }
    }
}